package com.sneaker.shower.controller;

import com.sneaker.shower.common.BaseView;
import com.sneaker.shower.entity.dto.AppraisedDTO;
import com.sneaker.shower.service.AppraisedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@Api("菜单相关API")
@Slf4j
public class AppraisedController {
    private final AppraisedService appraisedService;

    @Autowired
    public AppraisedController(AppraisedService appraisedService) {
        this.appraisedService = appraisedService;
    }

    @ApiOperation("add")
    @RequestMapping(value = "/appraised/add", method = RequestMethod.POST)
    public BaseView<Boolean> add(AppraisedDTO dto) {
        return new BaseView<>(appraisedService.add(dto));

    }

    @ApiOperation("modify")
    @RequestMapping(value = "/appraised/modify", method = RequestMethod.POST)
    public BaseView<Boolean> modify(AppraisedDTO dto) {
        return new BaseView<>(appraisedService.modify(dto));
    }

    @ApiOperation("del")
    @RequestMapping(value = "/appraised/del", method = RequestMethod.DELETE)
    public BaseView<Boolean> del(Long guid) {
        return new BaseView<>(appraisedService.del(guid));
    }

    @ApiOperation("list")
    @RequestMapping(value = "/appraised/list", method = RequestMethod.GET)
    public BaseView<List<AppraisedDTO>> list(Long orgnaizationGuid, Long productGuid) {
        return new BaseView<>(appraisedService.list(orgnaizationGuid, productGuid));
    }
}
